<template>
  <div class="imgs-item" v-loading="loading">
    <div class="imgs-png">
      <img :src="imgUrl" alt="卧理机" />
      <Client :isPhoto="true" left="80%" top="66%"  :PostionNumber="index * 1" />
    </div>
  </div>
</template>

<script>
import Client from "@/views/production/device/components/client.vue";
import {
  sendCameraText,
  sendRobotText,
  forceSignal,
} from "@/api/production/device";
export default {
  components: {
    Client,
  },
  props: {
    index: {
      type: [String, Number],
      default: 0,
    },
    showValue: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      dialogVisible: false,
      imgUrl:require('@/assets/images/recument3D.png'),
      loading:true
    };
  },
  methods: {
    goRecument(){
      this.$router.push({name:'Machine',params:{index:this.index}})
    },
    loadingImg(){
      let bgImg = new Image()
      bgImg.src = this.imgUrl
      bgImg.onerror = () => {
        console.log('img onerror');
      }
      bgImg.onload = () => {
        this.loading = false
      }
    },
    ClickEvent(path, value) {
      const that = this;
      let params = {
        line: this.index - 1,
        value,
      };
      this.$modal
        .confirm("请确认是否强制发送信号")
        .then(function () {
          forceSignal(path, params).then((res) => {
            that.$store.dispatch("listOperationStatus");
            that.$store.dispatch("listGlass");
            that.$message({
              type: "success",
              message: res.msg,
            });
          });
        })
        .catch(() => { });
    },
    sendCode(value, isPhoto, closeEvent) {
      if (isPhoto) {
        sendCameraText(value).then((res) => {
          if (res.code == 200) {
            this.$message({
              type: "success",
              message: res.msg,
            });
            closeEvent();
          } else {
            this.$message.error(res.msg);
          }
        });
      } else {
        sendRobotText(value).then((res) => {
          if (res.code == 200) {
            this.$message({
              type: "success",
              message: res.msg,
            });
            closeEvent();
          } else {
            this.$message.error(res.msg);
          }
        });
      }
    },
  },
  mounted(){
    this.loadingImg()
  }
};
</script>

<style lang="scss" scoped>
.imgs-item {
  height: 100%;
  max-height: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  // border-bottom: 1px solid #e6e6e6;
  overflow: hidden;

  .imgs-name {
    height: 100%;
    width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 180px;
    font-weight: bold;
    background-color: #46a6ff;
    color: #fff;
    cursor: pointer;
  }


  .imgs-png {
    position: relative;
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    img {
      width: 95%;
      height: 350px;
    }

    .deviceAction {
      flex: 1;
      padding: 10px 7px;

      .sub-title {
        font-size: 16px;
        font-weight: bold;
      }

      .action {
        display: flex;
        flex-direction: column;

        .line_index {
          display: flex;
          flex-direction: column;
          padding: 7px 0;
          .device_status {
            display: flex;
            
            span {
              margin-left: auto;
            }
          }
          .btnList{
            padding: 3px 0;
          }
        }
      }
    }
  }

  .btn {
    position: absolute;
  }
}
</style>